/**
 *  动态生成组件模板
 *  @ components 目录下命名规则 根据对应模块分类，根据模块module_name 创建
 *  modul_对应模块  (10 问题模块  20 检查项饼图  30 任务饼图  40 地图)
 */
const common = require.context('@common/views/dashboard/', true, /.vue$/);
const modules = require.context('@modules', true, /.vue$/);

const dashboard = {};

common.keys().forEach(key => {
	let pathArray = key.split('/');
	if (pathArray.length === 3) {
		dashboard[`${ pathArray[1] }Dashboard`] = common(key).default || common(key);
	}
});

modules.keys().forEach(key => {
	let pathArray = key.split('/');
	if (key.indexOf('dashboard') !== -1 && pathArray.length === 6) {
		dashboard[`${ pathArray[pathArray.length - 2] }Dashboard`] = modules(key).default || modules(key);
	}
});

export default dashboard;